VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "IScreen_HowToPlay"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'====================================================================================
'clsScreen_HowToPlay - The "How to Play" screen
'====================================================================================
Option Explicit

'This is a snap-in class for `Project.GameScreen`, shown on screen
Implements IScreen

'--- Graphics -----------------------------------------------------------------------
Private Background As New clsScrollingBG    'The scrolling background
Private Choice As Boolean

Private Title As New clsText
Private SubTitle As New clsText
Private MenuItem As New clsButton

'====================================================================================
'CLASS Initialize: Prepare the screen prior to showing
'====================================================================================
Private Sub Class_Initialize()
    'Setup background
    Background.Initialize "Candy", -2, 1
    
    'Create the menu item
    Set MenuItem.Font = Fonts.Menu
    MenuItem.Text = "Back"
    MenuItem.X = 640 - (MenuItem.Width + 56)
    MenuItem.Y = 480 - (MenuItem.Height + 56)
    
    'Create the title texts
    Set Title.DefaultFont = Fonts.Menu
    Title.FontStyle = 2
    Title.Text = "How To Play"
    Set SubTitle.DefaultFont = Fonts.Pastel
    SubTitle.FontStyle = 2
    SubTitle.Text = "~  C o n t r o l s  ~"
    
    'Start animation control
    ScreenMode = SM_Load
End Sub

'====================================================================================
'ISCREEN Animate: Animate the screen
'====================================================================================
Private Sub IScreen_Animate()
    'Which animation mode is the title screen in
    If ScreenMode = SM_Load Then
        'When loading the title screen, slide open the doors
        If Status.OpenDoors(STATUS_SPEED_STANDARD) Then ScreenMode = SM_Wait
    
    ElseIf ScreenMode = SM_Exit Then
        Select Case ModeStep
            Case 0
                If Status.CloseDoors(STATUS_SPEED_STANDARD) Then ModeStep = 1
                
            Case 1
                Project.StartTitleScreen
                  
        End Select
    End If
    
    'Scroll the background
    Background.Animate
End Sub

'====================================================================================
'ISCREEN Render: Draw the screen
'====================================================================================
Private Sub IScreen_Render(ByVal hDC As Long)
    'Draw the scrolling background
    Background.Render hDC
    
    'Screen title
    Title.Draw hDC, (640 - Title.Width) \ 2, 48
    SubTitle.Draw hDC, (640 - SubTitle.Width) \ 2, 85
    
    Fonts.Keys.DrawText hDC, 88, 119, "S"     'Shift+S is Up Arrow in the keys font
    Fonts.Keys.DrawText hDC, 61, 147, "Z"     'Shift+Z is Left Arrow
    Fonts.Keys.DrawText hDC, 88, 147, "X"     'Shift+X is Down Arrow
    Fonts.Keys.DrawText hDC, 115, 147, "C"    'Shift+C is Right Arrow
    Fonts.Pastel.DrawText hDC, 185, 146, "Use the arrow keys to move"
    
    Fonts.Keys.DrawText hDC, 75, 195, "B"     'B is Shift in the keys font
    Fonts.Pastel.DrawText hDC, 185, 198, "Slow down"
    
    Fonts.Keys.DrawText hDC, 88, 247, "~"     '~ Is Esc in the keys font
    Fonts.Pastel.DrawText hDC, 185, 250, "Pause / Continue"
    
    Fonts.Keys.DrawText hDC, 88, 299, "{"     '{ is F11 in the keys font
    Fonts.Pastel.DrawText hDC, 185, 302, "Enter / Exit Full Screen"
    
    'Draw the Menu button
    MenuItem.Draw hDC, True
    
    'Draw the cookies
    Sprites.Cookie.DrawEx hDC, MenuItem.X - 32, 400, 16, 16, 0, 0
    Sprites.Cookie.DrawEx hDC, MenuItem.X + MenuItem.Width + 16, 400, 16, 16, 0, 0
    
End Sub

'====================================================================================
'ISCREEN RenderTopBar: Render the top status bar display
'====================================================================================
Private Sub IScreen_RenderTopBar(ByVal hDC As Long)
    'This screen does not use the top status bar. This function has to be here in
    'order to comply with the IScreen Interface 'IScreen.cls'
End Sub

'====================================================================================
'ISCREEN RenderBottomBar: Render the bottom status bar display
'====================================================================================
Private Sub IScreen_RenderBottomBar(ByVal hDC As Long)
    'This screen does not use the bottom status bar. This function has to be here
    'in order to comply with the IScreen Interface 'IScreen.cls'
End Sub

'====================================================================================
'ISCREEN HandleKey: When the user presses keys....
'====================================================================================
Private Sub IScreen_HandleKey(ByVal KeyCode As Integer, ByVal Shift As Integer)
    'Ignore key presses when a menu selection has been made
    If ScreenMode = SM_Exit Then Exit Sub
    
    If (KeyCode = 13 Or KeyCode = 32) Then
        'If the user presses Enter or space bar (and the title screen isn't closing
        'already, the user has selected a menu action
        '- Animate() above will decide what to do
        ScreenMode = SM_Exit: Choice = True
    
    ElseIf KeyCode = vbKeyEscape Then
        'If the user presses ESC, return to the titlescreen
        ScreenMode = SM_Exit: Choice = False
        
    End If
End Sub

'====================================================================================
'ISCREEN HandleMouseMove: When the user moves the mouse over the screen
'====================================================================================
Private Sub IScreen_HandleMouseMove(ByVal MouseX As Single, ByVal MouseY As Single)
    'Is the mouse over a menu item?
    If ScreenMode < SM_Exit Then
        MenuItem.HitTest MouseX, MouseY
    End If
End Sub

'====================================================================================
'ISCREEN HandleMouseClick: When the user clicks on the screen...
'====================================================================================
Private Sub IScreen_HandleMouseClick(ByVal Button As Integer, ByVal Shift As Integer, ByVal MouseX As Integer, ByVal MouseY As Integer)
    'Is the mouse over a menu item?
    If ScreenMode < SM_Exit Then
        If MenuItem.HitTest(MouseX, MouseY) = True Then
            'Exit the scene
            Choice = True
            ScreenMode = SM_Exit
        End If
    End If
End Sub

'====================================================================================
'CLASS Terminate: Free up memory when the screen is unloaded
'====================================================================================
Private Sub Class_Terminate()
    Set Background = Nothing
    Set Title = Nothing
    Set SubTitle = Nothing
    Set MenuItem = Nothing
End Sub

'=== END ============================================================================
'This work is licenced under the Creative Commons Attribution 2.5 License
